package com.vpx.server.controller.system;

import com.vpx.server.bean.order.base.BaseDelOrder;
import com.vpx.server.bean.order.base.BaseIdStrOrder;
import com.vpx.server.bean.order.system.TemplateAttrOrder;
import com.vpx.server.bean.order.system.TemplateAttrPageOrder;
import com.vpx.server.bean.order.system.TemplateOrder;
import com.vpx.server.bean.order.system.TemplatePageOrder;
import com.vpx.server.bean.result.system.TemplateAttrPageResult;
import com.vpx.server.bean.result.system.TemplateAttrResult;
import com.vpx.server.bean.result.system.TemplatePageResult;
import com.vpx.server.bean.result.system.TemplateResult;
import com.vpx.server.framework.authority.AuthPoicy;
import com.vpx.server.framework.authority.RequestAuth;
import com.vpx.server.framework.base.ResultMsg;
import com.vpx.server.service.system.TemplateAttrService;
import com.vpx.server.service.system.TemplateService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 工程管理
 */
@RestController
@RequestMapping(value = "/api/templateAttr")
@Api(tags = "协议模板属性管理")
public class TemplateAttrController {

    @Autowired
    private TemplateAttrService templateAttrService;

    @PostMapping("/insertTemplateAttr")
    @ApiOperation("新增协议模板属性")
    //@RequestAuth(poicy = AuthPoicy.AUTH)
    public ResultMsg insert(@Validated @RequestBody TemplateAttrOrder order) {
        return templateAttrService.saveTemplateAttr(order);
    }

    @DeleteMapping("/deleteTemplateAttr")
    @ApiOperation("删除协议模板属性")
    @RequestAuth(poicy = AuthPoicy.AUTH)
    public ResultMsg deleteTemplateAttr(@Validated @RequestBody BaseDelOrder order) {
        return templateAttrService.deleteTemplateAttr(order);
    }

    @PostMapping("/updateTemplateAttr")
    @ApiOperation("修改协议模板属性")
    @RequestAuth(poicy = AuthPoicy.AUTH)
    public ResultMsg updateById(@RequestBody TemplateAttrOrder order) {
        return templateAttrService.updateTemplateAttrById(order);
    }

    @GetMapping("/selectTemplateAttrById")
    @ApiOperation("查询工程流程")
    @RequestAuth(poicy = AuthPoicy.AUTH)
    public ResultMsg<TemplateAttrResult> selectById(BaseIdStrOrder order) {
        return templateAttrService.selectTemplateAttrById(order);
    }

    @GetMapping("/pageQueryTemplate")
    @ApiOperation("分页查询工程")
    //@RequestAuth(poicy = AuthPoicy.AUTH)
    public ResultMsg<TemplateAttrPageResult> pageQueryTemplate(TemplateAttrPageOrder order) {

        return templateAttrService.pageQueryTemplate(order);
    }



}
